<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lost-news</title>
    <link rel="stylesheet" href="css/show.css">
    <script>
        function check(){
            var ltitle = document.getElementById("ltitle").value;
            var lmsg = document.getElementById("lmsg").value;
            var img = document.getElementById("img").value;
            if (ltitle == ""){
                alert("标题不能为空！");
                return false;
            }
            if (lmsg == ""){
                alert("内容不能为空！");
                return false;
            }
            if (img.length == 0 || img == ""){
                alert("请选择上传文件！");
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
	
	<jsp:include page="top.jsp"></jsp:include>

    <div class="lost">
        <form action="${pageContext.request.contextPath}/addLost" method="post" enctype="multipart/form-data"  onsubmit="return check()">
            <div class="lost-title">
                <div class="title">
                    <p>标题</p>
                    <input id="ltitle" type="text" name="ltitle" required="required"/>
                </div>
            </div>
            <div class="lost-text">
                <div class="text">
                    <p>内容</p>
                    <textarea id="lmsg" cols="69" rows="9" name="lmsg" required="required"></textarea>
                </div>
            </div>
            <div class="lost-type">
 			分类：<br><c:forEach items="${TYPES_SESSION }" var="type">
	                <input type="checkbox" name="type" value="${type.tid }">${type.tname }&nbsp;&nbsp;&nbsp;&nbsp;
	            </c:forEach>
            </div>
            <div class="lost-img">
                <span>添加照片</span>
                <input id="img" type="file" name="limg" required="required"/>
            </div>
            <button type="submit">发&nbsp;&nbsp;&nbsp;&nbsp;布</button>
        </form>
    </div>
    <br>
</body>
</html>